// The Vue build version to load with the `import` command
// (runtime-only or standalone) has been set in webpack.base.conf with an alias.
import Vue from 'vue'
import MintUI from 'mint-ui'
import 'mint-ui/lib/style.css'
import App from './App'
import router from './router'
import './config/rem'
import VueAwesomeSwiper from 'vue-awesome-swiper'
import 'swiper/dist/css/swiper.css'
import './common/style/iconfont.css'
import axios from 'axios'
import VueAxios from 'vue-axios'
import VueAMap from 'vue-amap'

import store from './store/index.js'
import '../static/mui.min.js'

Vue.use(MintUI)
Vue.use(VueAxios, axios)
Vue.use(VueAMap)
Vue.config.productionTip = false
VueAMap.initAMapApiLoader({
  key: 'c90c65b759b76fdee57ec16ea2db0527',
  plugin: ['AMap.Autocomplete', 'AMap.PlaceSearch', 'AMap.Scale', 'AMap.OverView', 'AMap.ToolBar', 'AMap.MapType', 'AMap.PolyEditor', 'AMap.CircleEditor', 'Geolocation'],
  // 默认高德 sdk 版本为 1.4.4
  v: '1.4.4'
})
router.beforeEach((to, from, next) => {
  if (to.meta.requireAuth) {
    if (store.state.isLogin) {
//    if (to.meta.isReal) {
//      if (store.state.isReal) {
//        next()
//      } else {
//        next({
//          path: '/send',
//          query: {redirect: to.fullPath}
//        })
//      }
//    } else{
//      next()
//    }
      next()
    } else {
      next({
        path: '/login',
        query: {redirect: to.fullPath}
      })
    }
  } else {
    next()
  }
})

/* eslint-disable no-new */
new Vue({
  el: '#app',
  router,
  store,
  components: { App },
  template: '<App/>'
})
Vue.use(VueAwesomeSwiper)
